﻿using Basic.FormCollect;
using Basic.FormLocalEvent.Model;
using Basic.FormModel.DB;
using Basic.FormRemoteModel.QueryGroup.Model;
using Basic.FormService.Interface;
using WeDonekRpc.Client;

namespace Basic.FormService.lmpl
{
    internal class PhyQueryGroupService : IPhyQueryGroupService
    {
        private readonly IQueryGroupCollect _Group;

        public PhyQueryGroupService ( IQueryGroupCollect group )
        {
            this._Group = group;
        }

        public long Add ( QueryGroupAdd data )
        {
            return this._Group.Add(data);
        }
        public void Delete ( long id )
        {
            DBPhysicalQueryGroup source = this._Group.Get(id);
            this._Group.Delete(source);
            new PhyQueryGroupEvent(source).Send("Delete");
        }
        public QueryGroupDto Get ( long id )
        {
            DBPhysicalQueryGroup source = this._Group.Get(id);
            return source.ConvertMap<DBPhysicalQueryGroup, QueryGroupDto>();
        }

        public bool Set ( long id, QueryGroupSet set )
        {
            DBPhysicalQueryGroup source = this._Group.Get(id);
            return this._Group.Set(source, set);
        }
    }
}
